//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Runtime.InteropServices;
using System.Security;

namespace OpenLS.Spreadsheet.Formats.Biff
{
    internal class API
    {
        [DllImport("ole32.dll")]
        public static extern UInt32 StgCreateStorageEx(
            [MarshalAs(UnmanagedType.LPWStr), In] string pwcsName,
            STGM grfMode,
            STGFMT stgfmt,
            uint grfAttrs,
            [In] IntPtr pStgOptions,
            [In] IntPtr reserved2,
            [In] ref Guid riid,
            [MarshalAs(UnmanagedType.IUnknown), Out] out object ppObjectOpen); 

        

        [DllImport("ole32.dll", PreserveSig = false)]
        public static extern IStorage StgOpenStorageOnILockBytes(ILockBytes iLockBytes, IStorage pStgPriority,
                                                                 int grfMode, int sndExcluded, int reserved);


        [SuppressUnmanagedCodeSecurity, DllImport("ole32.dll")]
        internal static extern int StgOpenStorageEx(
            [In, MarshalAs(UnmanagedType.LPWStr)] string pwcsName,
            int grfMode, int stgfmt, int grfAttrs, IntPtr pStgOptions, IntPtr reserved2,
            ref Guid riid, out IStorage ppObjectOpen);

        [DllImport("ole32.dll", SetLastError = true)]
        public static extern int StgOpenStorage([MarshalAs(UnmanagedType.LPWStr)] string wcsName, IntPtr stgPriority,
                                                STGM grfMode, IntPtr snbExclude, uint reserved,
                                                out IStorage storage);

        [DllImport("ole32.dll", SetLastError = false)]
        public static extern IStorage StgOpenStorage([MarshalAs(UnmanagedType.LPWStr)] string wcsName,
                                                     IntPtr stgPriority, STGM grfMode, IntPtr snbExclude,
                                                     uint reserved);
    }
}